<?php
/**
 * Created by zengwei.
 * Date: 2019/10/28
 * Time: 17:41
 * Function:
 */

namespace App\Http\Controllers\Api;


use App\Http\Controllers\Controller;
use App\Models\City;

class CityController extends Controller
{
    public function index(){
        $cities = City::get();
        return response()->json(successDataFormat($cities));
    }

    public function getBySlug($slug){
        $city = City::where('slug',$slug)
            ->with(['cafes','cafes.company'])
            ->first();
        if($city){
            return response()->json(successDataFormat($city));
        }else{
            return response()->json(null,404);
        }
    }

}
